#include "CameraGame.h"
#include "Game.h"
#include "World.h"

CameraGame::CameraGame(void)
{
	Camera[0] = 0;
	Camera[1] = 0;
}

CameraGame::~CameraGame(void)
{

}
void CameraGame::creatCamera()
{
	mSmgr = Game::mDevice->getSceneManager();
	Camera[0] = mSmgr->addCameraSceneNodeMaya();
	scene::ISceneNodeAnimator* anim = mSmgr->createCollisionResponseAnimator(
		World::metaSelector, Camera[0] , core::vector3df(5,5,5),
		core::vector3df(0,0,0));

	Camera[0]->addAnimator(anim);
	anim->drop();
	Camera[0]->setFarValue(20000.f);
	Camera[0]->setPosition(core::vector3df(0, 50, 0));
	// Maya cameras reposition themselves relative to their target, so target the location
	// where the mesh scene node is placed.
	Camera[0]->setTarget(core::vector3df(50,30,50));

	Camera[1] = mSmgr->addCameraSceneNodeFPS();
	anim = mSmgr->createCollisionResponseAnimator(
		World::metaSelector, Camera[1] , core::vector3df(5,5,5),
		core::vector3df(0,0,0));

	Camera[1]->addAnimator(anim);
	anim->drop();
	Camera[1]->setFarValue(20000.f);
	Camera[1]->setPosition(core::vector3df(0, 100, 0));
	Camera[1]->setTarget(core::vector3df(50,30,50));

}
void CameraGame::setActiveCamera(scene::ICameraSceneNode* newActive)
{
	if (0 == Game::mDevice)	
		return;

	scene::ICameraSceneNode * active = Game::mDevice->getSceneManager()->getActiveCamera();
	active->setInputReceiverEnabled(false);

	newActive->setInputReceiverEnabled(true);
	Game::mDevice->getSceneManager()->setActiveCamera(newActive);
}